# Maintainer: team/gnome <pabloyoyoista@postmarketos.org>
pkgname=papers
pkgver=47.0
pkgrel=0
pkgdesc="simple document viewer for GNOME desktop"
url="https://apps.gnome.org/Papers/"
# s390x blocked by mozjs91 -> nautilus-dev
arch="all !s390x"
license="GPL-2.0-or-later"
depends="
	adwaita-icon-theme
	gsettings-desktop-schemas
	"
depends_dev="
	gobject-introspection-dev
	gtk4.0-dev
	libadwaita-dev
	libgxps-dev
	libspectre-dev
	poppler-dev
	tiff-dev
	"
makedepends="
	$depends_dev
	adwaita-icon-theme-dev
	cairo-dev
	cargo
	dbus-dev
	desktop-file-utils
	djvulibre-dev
	exempi-dev
	gdk-pixbuf-dev
	glib-dev
	itstool
	libarchive-dev
	libadwaita-dev
	libsecret-dev
	meson
	nautilus-dev
	"
subpackages="
	$pkgname-dev
	$pkgname-doc
	$pkgname-lang
	$pkgname-nautilus
	$pkgname-libs
"
# needed to download rust crates
options="net"
source="https://download.gnome.org/sources/papers/${pkgver%.*}/papers-$pkgver.tar.xz
	0001-fix_-dev.patch
	0002-no_rustfmt.patch"

build() {
	abuild-meson \
		-Db_lto=true \
		-Ddocumentation=false \
		. output
	meson compile -C output
}

check() {
	meson test --no-rebuild -v -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
}

nautilus() {
	pkgdesc="$pkgname (Nautilus extension)"
	install_if="$pkgname=$pkgver-r$pkgrel nautilus"

	amove usr/lib/nautilus
}

libs() {
	default_libs
	amove usr/lib/papers
	amove usr/lib/girepository-1.0
}

doc() {
	default_doc
	if [ -d "$pkgdir"/usr/share/help ]; then
		mv "$pkgdir"/usr/share/help "$subpkgdir"/usr/share/
	fi
}

sha512sums="
b95675083756bc54881e1317eaa5d14f0a41d10b915bcb20390cd4e1d6a9a87a855f0ec54e833913189cab8e11c4e332600c8b9532f7cd510a5a21107d7ab0a2  papers-47.0.tar.xz
f39eb462c697a8577af54d03e437e81381c727b789f4066303d52ce4ae68732ad5f0ce5a2d0588cc0f1bebbee60252535f02e0a926917174a60a35255f63fa98  0001-fix_-dev.patch
61c37319968bc939cd1f89a654ce8ea53f402bf161be65d1f4fd6df3b7bf76c5ff8c71f93c356864cba9da70d4a047ed08c5971d88e9a4759c3fe90ace8b82fb  0002-no_rustfmt.patch
"
